module.exports = {
  publicPath: '/',
  productionSourceMap: false,
  filenameHashing: true,
  lintOnSave: false,
  configureWebpack: {
    resolve: {
      //别名
      alias: {
        '@': '/src'
      }
    }
  },
  chainWebpack: config => {
    // set worker-loader
    config.module
      .rule('worker')
      .test(/\.worker\.js$/)
      .use('worker-loader')
      .loader('worker-loader')
      .end();
    // 解决：worker 热更新问题
    config.module.rule('js').exclude.add(/\.worker\.js$/);
    // 解决：“window is undefined”报错，这个是因为worker线程中不存在window对象，因此不能直接使用，要用this代替
    config.output.globalObject('this')
    if (process.env.NODE_ENV === 'production') {
      //js hash
      config.output.filename('[name].[chunkhash:7].js')
        .chunkFilename('[name].[chunkhash:7].js').end()
      //css hash
      config.plugin('extract-css').tap(args => [{
        filename: `[name].[chunkhash:7].css`,
        chunkFilename: `[name].[chunkhash:7].css`
      }])
    }
  },
  devServer: {
    open: true,
    port: 10222,
    proxy: {
      '/api': {
        target: 'http://192.168.100.21:5001',
        pathRewrite: {
          '^/api': ''
        }
      }
    },
  },

}